package com.ruoyi.basebill.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basebill.domain.OmsDeliverbill;
import com.ruoyi.basebill.service.IOmsDeliverbillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * OMS发货确认Controller
 * 
 * @author ptt
 * @date 2023-02-10
 */
@RestController
@RequestMapping("/settlementCenter/basebill/deliverbill")
public class OmsDeliverbillController extends BaseController
{
    @Autowired
    private IOmsDeliverbillService omsDeliverbillService;

    /**
     * 查询OMS发货确认列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:deliverbill:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmsDeliverbill omsDeliverbill)
    {
        startPage();
        List<OmsDeliverbill> list = omsDeliverbillService.selectOmsDeliverbillList(omsDeliverbill);
        return getDataTable(list);
    }

    /**
     * 导出OMS发货确认列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:deliverbill:export')")
    @Log(title = "OMS发货确认", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OmsDeliverbill omsDeliverbill)
    {
        List<OmsDeliverbill> list = omsDeliverbillService.selectOmsDeliverbillDetailList(omsDeliverbill);
        ExcelUtil<OmsDeliverbill> util = new ExcelUtil<OmsDeliverbill>(OmsDeliverbill.class);
        util.exportExcel(response, list, "OMS发货确认数据");
    }

    /**
     * 获取OMS发货确认详细信息
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:deliverbill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(omsDeliverbillService.selectOmsDeliverbillById(id));
    }

    /**
     * 新增OMS发货确认
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:deliverbill:add')")
    @Log(title = "OMS发货确认", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmsDeliverbill omsDeliverbill)
    {
        return toAjax(omsDeliverbillService.insertOmsDeliverbill(omsDeliverbill));
    }

    /**
     * 修改OMS发货确认
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:deliverbill:edit')")
    @Log(title = "OMS发货确认", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmsDeliverbill omsDeliverbill)
    {
        return toAjax(omsDeliverbillService.updateOmsDeliverbill(omsDeliverbill));
    }

    /**
     * 删除OMS发货确认
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:deliverbill:remove')")
    @Log(title = "OMS发货确认", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(omsDeliverbillService.deleteOmsDeliverbillByIds(ids));
    }
}
